package com.zzl.finance.data.controller;

import com.zzl.apidoc.annotation.ApidocController;
import com.zzl.apidoc.annotation.ApidocOperation;
import com.zzl.apidoc.annotation.ApidocParam;
import com.zzl.general.common.apidoc.annotation.ApidocResultKeyValR;
import com.zzl.general.common.apidoc.annotation.ApidocReturnR;
import com.zzl.general.common.apidoc.constants.ResultTypeInR;
import com.zzl.general.common.ctrl.WebBaseCtrl;
import com.zzl.general.common.exception.SysException;
import com.zzl.general.common.utils.EnumUtils;
import com.zzl.general.common.utils.KeyValue;
import com.zzl.general.common.utils.LogUtils;
import com.zzl.general.common.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 枚举类
 *
 * @author gull
 * @date 2022-08-26 13:26:44
 */
@ApidocController("枚举类")
@RestController
@SuppressWarnings("javadoc")
@RequestMapping("data/enum")
@Slf4j
public class EnumController extends WebBaseCtrl {


    /**
     * 列表
     */
    @GetMapping("/getEnumList/{name}")
    @ApidocOperation(description = "枚举类集合", operationId = "log/enum" + "/getEnumList")
    @ApidocReturnR(otherkv = {
            @ApidocResultKeyValR(resultType = ResultTypeInR.TYPE_COLLOCTION, key = "list", valueClass = KeyValue.class)
    })
    public Result list(@ApidocParam(description = "枚举类全限定名:" +
            "接入产品：com.zzl.finance.data.constant.type.AccessProductTypeEnum；" +
            "企业类型：com.zzl.finance.data.constant.type.EnterpriseCategoryConstant;" +
            "资金方类型下拉框：com.zzl.finance.data.constant.type.FinancierTypeEnum；" +
            "", name = "name", required = true) @PathVariable("name") String name) {
        try {
            //com.zzl.gold.student.constant.ProtocolPushStatusEnum
            return Result.ok().list(EnumUtils.getEnums(name));
        } catch (SysException e) {
            LogUtils.logSysException(log, e);
            return Result.error(e.getMsg());
        }

    }


}
